const name1 = document.querySelector("#inputName");
const price = document.querySelector("#inputPrice");
const num = document.querySelector("#inputNum");
const info = document.querySelector('#info')
// console.log(btnAdd)
// console.log(btnAdd)
document.querySelector("#btn-add").onclick = function() {
  //获取了三个输入框
  console.log(loginState)
  if(loginState === 'on'){
    console.log(loginState)
    nameValue = name1.value;
    priceValue = price.value;
    numValue = num.value;
    utils.fetch('./api/v1/shop/add.php',{ name:nameValue, price:priceValue, num:numValue}).then((resp)=>{
        info.className = 'text-center'
        info.innerHTML = resp.body.msg
        if (resp.code ===200){
            info.classList.add('text-success')
            setTimeout(() => {
                info.innerHTML = ''
                $('#addModal').modal('hide')
                // 重新获取一次最新的数据
                getData()
            }, 1000)
        }else{
          info.classList.add('text-danger')
          setTimeout(() => {
            info.innerHTML = ''
          }, 1000)
        }
    })
  }else{
    alert('请先登录')
  }
 
};

$('#addModal').on('hidden.bs.modal', function (e) {
    inputName.value = inputPrice.value = inputNum.value = ''
  })
